#include <cstdio>
#include <algorithm>
const int max = 100;
struct tag
{
    int l, r;
} I[max];
bool cmp(tag l, tag r)
{
    return l.r < r.r;
}
int main()
{
    int N;
    while (scanf("%d", &N), N != 0)
    {
        for (int i = 0; i < N; ++i)
        {
            getchar();//注意输入缓冲区的问题
            //scanf() retrun zero in the event of an early matching failure
            int ret = scanf("(%d,%d)", &I[i].l, &I[i].r);
            printf("ret=%d\n", ret);
            //scanf("%d%d", &I[i].l, &I[i].r);
        }
        std::sort(I, I + N, cmp);
        int count = 1;
        int trace = 0;
        for (int i = 1; i < N; ++i)
        {
            if (I[i].l >= I[trace].r)
            {
                ++count;
                trace = i;
            }
        }
        printf("%d\n", count);
    }
}